package com.base.common.model.request;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 通用分页请求
 *
 * @author admin
 * @date 2020/5/26 AM9:38
 */
@ApiModel(value = "PageBaseRequest", description = "通用分页请求")
@Data
public class JsonRequest<P> extends CommonRequest implements java.io.Serializable {
    /**
     * 默认每页展示数据条数，取值为20
     */
    public static final Integer DEFAULT_SIZE = 20;

    /**
     * 单页面最大查询数据条数，取值为1000
     */
    public static final Integer MAX_SIZE = 1000;

    /**
     * 分页查询参数：查询页码，默认取值为1，即查询第一页
     */
    @ApiModelProperty(notes = "查询页码")
    private Integer current = 1;

    /**
     * 分页查询参数：查询页面数据条数，默认取值为MAX_SIZE
     */
    @ApiModelProperty(notes = "每页条数")
    private Integer size = DEFAULT_SIZE;

    /**
     * 业务请求-数据
     */
    @ApiModelProperty(notes = "业务请求-数据")
    private P param;

    /**
     * <p>Title: 构造函数</p>
     */
    public JsonRequest() {
    }

    public JsonRequest(P param) {
        this.param = param;
    }

    public void setSize(Integer size) {
        if (size > MAX_SIZE) {
            this.size = MAX_SIZE;
        } else {
            this.size = size;
        }
    }
}